﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace QuanLyKhachSan
{
    public partial class UC_TienNghi_Edit : System.Web.UI.UserControl
    {
        private int TienNghiID = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.Request.QueryString["TienNghiID"] != null)
                {
                    TienNghiID = int.Parse(this.Request.QueryString["TienNghiID"].ToString());
                }
                if (!Page.IsPostBack)
                {
                    if (TienNghiID != -1)
                    {
                        TienNghi_Load();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// TienNghi_Load
        /// </summary>
        protected void TienNghi_Load()
        {
            try
            {
                TienNghiInfo item = TienNghiBLL.TienNghi_GetItem(TienNghiID);
                txtTenTienNghi.Text = item.TienNghiName;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void cmdOK_Click(object sender, EventArgs e)
        {
            try
            {
                string TienNghiName = txtTenTienNghi.Text;
                if (TienNghiID == -1)
                {
                    TienNghiBLL.TienNghi_Add(TienNghiName,0);
                }
                else
                {
                    TienNghiBLL.TienNghi_Edit(TienNghiID, TienNghiName, 0);   
                }
                hfStatus.Value = "1";
            }
            catch (Exception)
            {

                throw;
            }
        }
}
}
